using System.Collections.Generic;
using System.Linq;
using Godot;

namespace Arcane.Source.Client.Extensions;

public static class TupleExt
{
    public static KeyValuePair<K, V> ToKVPair<K, V>(this (K, V) tuple) => new(tuple.Item1, tuple.Item2);

    public static (K, V) ToTuple<K, V>(this KeyValuePair<K, V> pair)
    {
        var (key, val) = pair;
        return (key, val);
    }

    public static Dictionary<K, V> ToDictionary<K, V>(this (K, V)[] tuples) => tuples.Select(ToKVPair).ToDictionary();

    public static Vector2 ToVector(this (float x, float y) tuple) => new(tuple.x, tuple.y);
    public static Vector2I ToVector(this (int x, int y) tuple) => new(tuple.x, tuple.y);
}